package com.jieshuibao.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jieshuibao.mapper.AdvisoryRecordingMapper;
import com.jieshuibao.mapper.AdvisoryUserExMapper;
import com.jieshuibao.mapper.AdvisoryUserMapper;
import com.jieshuibao.model.db.AdvisoryRecording;
import com.jieshuibao.model.db.AdvisoryUser;
import com.jieshuibao.model.db.AdvisoryUserExample;
import com.jieshuibao.model.domain.AdvisoryUserEx;

@Service
public class AdvisoryUserService{
	
	@Resource
	private AdvisoryUserMapper advisoryUserMapper;
	
	@Resource
	private AdvisoryUserExMapper advisoryUserExMapper;
	
	@Resource
	private AdvisoryRecordingMapper advisoryRecordingMapper;
	
	public void addAdvisoryUser(AdvisoryUser advisoryUser) {
		advisoryUserMapper.insertSelective(advisoryUser);
	}
	
	public void delAdvisoryUserByUuid(String uuid) {
		advisoryUserMapper.deleteByPrimaryKey(uuid);
	}
	
	public void updateAdvisoryUser(AdvisoryUser advisoryUser) {
		advisoryUserMapper.updateByPrimaryKeySelective(advisoryUser);
	}
	
	public AdvisoryUser getAdvisoryUserByUuid(String uuid) {
		return advisoryUserMapper.selectByPrimaryKey(uuid);
	}
	
	public List<AdvisoryUser> getPageAdvisoryUser(AdvisoryUserExample advisoryUserExample) {
		return advisoryUserMapper.selectPage(advisoryUserExample);
	}
	
	public List<AdvisoryUser> getAdvisoryUserByExample(AdvisoryUserExample advisoryUserExample) {
		return advisoryUserMapper.selectByExample(advisoryUserExample);
	}
	
	public int countAdvisoryUser(AdvisoryUserExample advisoryUserExample) {
		return advisoryUserMapper.countByExample(advisoryUserExample);
	}
	
	public List<AdvisoryUserEx> getAdvisoryUsersByExample(AdvisoryUserExample example){
		
		return advisoryUserExMapper.selectPageAdvisoryUser(example);
	}
	
	public void updateAdvisoryUserAndRecording(AdvisoryUser advisoryUser1,AdvisoryUser advisoryUser2,AdvisoryRecording advisoryRecording){
		if(advisoryUser1!=null&&advisoryUser2!=null){
			advisoryUserMapper.updateByPrimaryKeySelective(advisoryUser1);
			advisoryUserMapper.updateByPrimaryKeySelective(advisoryUser2);
		}
		
		if(advisoryRecording!=null){
			advisoryRecordingMapper.insertSelective(advisoryRecording);
		}
	}
	
	
}
